using System;
using System.Collections.Generic;

namespace MEA.AE_Data
{
	public class FlashBlockData : IComparable
	{
		public struct XMLFlashData
		{
			public byte[] buf;

			public uint startAdr;

			public uint checkSum;

			public bool blockCheckable;

			public bool blockEraseable;

			public uint chksumStartAdr;

			public uint chksumEndAdr;

			public uint eraseStartAdr;

			public uint eraseEndAdr;

			public uint id;

			public uint number;

			public uint length;

			public FlashBlock.EFD_Types fdType;
		}

		private bool blockEraseable;

		private bool blockCheckable;

		private uint eraseStartAdr;

		private uint eraseEndAdr;

		private uint chksumStartAdr;

		private uint chksumEndAdr;

		private uint writeStartAdr;

		private uint length;

		private uint id;

		private uint number;

		private uint checkSum;

		private List<byte> buffer;

		public FlashBlock.EFD_Types fdType = FlashBlock.EFD_Types.eFD_NoEFD_Type;

		public bool BlockEraseable
		{
			get
			{
				return blockEraseable;
			}
		}

		public bool BlockCheckable
		{
			get
			{
				return blockCheckable;
			}
		}

		public uint EraseStartAdr
		{
			get
			{
				return eraseStartAdr;
			}
		}

		public uint EraseEndAdr
		{
			get
			{
				return eraseEndAdr;
			}
		}

		public uint ChksumStartAdr
		{
			get
			{
				return chksumStartAdr;
			}
		}

		public uint ChksumEndAdr
		{
			get
			{
				return chksumEndAdr;
			}
		}

		public uint WriteStartAdr
		{
			get
			{
				return writeStartAdr;
			}
		}

		public uint Length
		{
			get
			{
				return length;
			}
		}

		public uint Id
		{
			get
			{
				return id;
			}
		}

		public uint Number
		{
			get
			{
				return number;
			}
		}

		public uint CheckSum
		{
			get
			{
				return checkSum;
			}
		}

		public List<byte> Buffer
		{
			get
			{
				return buffer;
			}
		}

		public FlashBlockData(ref XMLFlashData data, bool blockEraseable)
		{
			buffer = new List<byte>(data.buf);
			writeStartAdr = data.startAdr;
			checkSum = data.checkSum;
			chksumStartAdr = data.chksumStartAdr;
			chksumEndAdr = data.chksumEndAdr;
			blockCheckable = data.blockCheckable;
			eraseStartAdr = data.eraseStartAdr;
			eraseEndAdr = data.eraseEndAdr;
			this.blockEraseable = data.blockEraseable;
			id = data.id;
			number = data.number;
			length = data.length;
			fdType = data.fdType;
		}

		public int CompareTo(object obj)
		{
			if (obj is FlashBlockData)
			{
				FlashBlockData flashBlockData = (FlashBlockData)obj;
				return number.CompareTo(flashBlockData.Number);
			}
			throw new Exception("object is not of type FlashSubBlockData");
		}
	}
}
